{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "3873706a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FFFEFEFEf\n",
      "encoded message is:  PPPOPOPOp\n",
      "decoded message is:  FFFEFEFEf\n"
     ]
    }
   ],
   "source": [
    "'''Encrypt 26 letters, including upper and lower cases, code parameter indicates how many letters to move.'''\n",
    "message = input()\n",
    "raw_message = \"abcdefghijklmnopqrstuvwxyz\"\n",
    "# encode message fu\n",
    "def message_encode(letters,encode_code):\n",
    "    message_to_encode = \"\"\n",
    "    for l in letters:\n",
    "        if l.isalpha():\n",
    "            if l.isupper():\n",
    "                l_low = l.lower()\n",
    "                l_index = raw_message.index(l_low)\n",
    "                encoded_letter = raw_message[(encode_code+l_index)%26]\n",
    "                encoded_letter = encoded_letter.upper()\n",
    "                message_to_encode += encoded_letter\n",
    "            else:\n",
    "                l_index = raw_message.index(l)\n",
    "                encoded_letter = raw_message[(encode_code+l_index)%26]\n",
    "                message_to_encode += encoded_letter\n",
    "        else:\n",
    "            message_to_encode += l\n",
    "    return message_to_encode\n",
    "def message_decode(letters, decode_code):\n",
    "    message_to_decode = \"\"\n",
    "    for l in letters:\n",
    "        if l.isalpha():\n",
    "            if l.isupper():\n",
    "                l_low = l.lower()\n",
    "                l_index = raw_message.index(l_low)\n",
    "                decoded_letter = raw_message[(l_index-decode_code)%26]\n",
    "                decoded_letter = decoded_letter.upper()\n",
    "                message_to_decode += decoded_letter\n",
    "            else:\n",
    "                l_index = raw_message.index(l)\n",
    "                decoded_letter = raw_message[(l_index-decode_code)%26]\n",
    "                message_to_decode += decoded_letter\n",
    "        else:\n",
    "            message_to_decode += l\n",
    "    return message_to_decode\n",
    "en_message = message_encode(message, 10)\n",
    "print('encoded message is: ', en_message)\n",
    "de_message = message_decode(en_message, 10)\n",
    "print('decoded message is: ', de_message)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "7082a9f3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "74a252ff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "getge\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "009897f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'capca'"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "message_decode(message, 30\n",
    "              )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "703e6822",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6060f9bb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
